<?php

use think\migration\Migrator;
use think\migration\db\Column;

class IntegralTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        // 积分表
        $table = $this->table('integra');
        $table->addColumn('uid', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '用户uid'))
            ->addColumn('value', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '积分值：默认为0'))
            ->addColumn('type', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '积分类型：1 收入，2 支出'))
            ->addColumn('type_describe', 'boolean', array('limit' => 1, 'default' => 0, 'comment' => '积分类型描述：0，无效，1 用户登录，2 用户签到，3 用户参与多人拼团，4，用户参与10人拼团，5 用户参与5人拼团，6 积分兑换金豆，等等'))
            ->addColumn('create_year_time', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '创建年时间'))
            ->addColumn('create_month_time', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '创建月时间'))
            ->addColumn('create_day_time', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '创建日时间'))
            ->addColumn('create_time', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '创建时间'))
            ->addColumn('update_time', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '修改时间'))
            ->create();
    }
}
